package com.kelvin.paopao.module.market.market.EditRecieveLocation;

import com.kelvin.kelvinlib.utils.ToastUtil;
import com.kelvin.paopao.api.RetrofitService;
import com.kelvin.paopao.api.responseBean.CommonListResponse;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

/**
 * Created by MCK on 2017/5/25.
 */

public class EditLocationPresenter implements IEditLocationPresenter {
    private EditRecieveLocationActivity mView;

    public EditLocationPresenter(EditRecieveLocationActivity view) {
        this.mView = view;
    }

    @Override
    public void addLocation(String username, String phone, String address,
                            String lname, String lat, String lng) {
        RetrofitService.addLocationPick(address, phone,
                username, lname, lat, lng).subscribe(new Consumer<CommonListResponse>() {
            @Override
            public void accept(@NonNull CommonListResponse commonListResponse) throws Exception {
                if (commonListResponse.getReason().equals("成功")) {
                    ToastUtil.showToast(mView, "添加成功");
                    mView.finish();
                } else {
                    ToastUtil.showToast(mView, "添加失败");
                }
            }
        });
    }

    @Override
    public void getData(boolean isRefresh) {

    }

    @Override
    public void getMoreData() {

    }
}
